package com.shirojwt.controller;

import com.shirojwt.com.lang.JwtResultMap;
import io.jsonwebtoken.Jwt;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author chenguo
 * @date 2021/10/12 3:57 下午
 */

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private JwtResultMap resultMap;

    @RequiresRoles(logical = Logical.OR, value = {"user", "admin"})
    @GetMapping("/enter")
    public JwtResultMap enter(){
        return resultMap.success().code(200).message("欢迎进入用户界面");
    }

    @RequiresPermissions("vip")
    @RequiresRoles(logical = Logical.OR, value = {"user", "admin"})
    @GetMapping("/getMessage")
    public JwtResultMap getMessage(){
        return resultMap.success().code(200).message("成功获得VIP信息");
    }
}
